<!--钱包列表-->
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="钱包地址" prop="walletAddress">
        <el-input v-model="queryParams.walletAddress" placeholder="请输入钱包地址" clearable
                  @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="用户名" prop="userName">
        <el-input v-model="queryParams.userName" placeholder="请输入用户名" clearable
                  @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="钱包网络" prop="walletId">
        <el-select v-model="queryParams.walletId" filterable remote reserve-keyword placeholder="请输入关键词" :remote-method="getWallet" :loading="loading">
          <el-option v-for="item in walletList" :key="item.id" :label="item.network" :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="钱包地址" align="center" prop="cardNumber" width="180" :show-overflow-tooltip="true" />
      <el-table-column label="用户名" align="center" prop="userName" width="180" :show-overflow-tooltip="true" />
      <el-table-column label="钱包网络" align="center" prop="bankName" width="180" :show-overflow-tooltip="true" />
      <el-table-column label="手机号" align="center" prop="phone" width="180" :show-overflow-tooltip="true"/>
      <el-table-column label="钱包状态" align="center" prop="bankState" width="180" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <el-tag type="success" v-if="scope.row.walletState == '1'">可用</el-tag>
          <el-tag type="warning" v-if="scope.row.walletState == '0'">不可用</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180"
                       :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{m}/{d}/{y}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                     v-hasPermi="['car:user:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                @pagination="getList" />

  </div>
</template>

<script>
import { list,deleteData,manageList } from "@/api/bank/wallent";
import RemoteSelect from '@/components/RemoteSelect/index.vue'

export default {
  name: "walletList",
  components: { RemoteSelect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 用户完成线下理财信息表格数据
      dataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        type:1
      },
      walletList:[],
    };
  },
  created() {
    this.getWallet();
    this.getList();
  },
  methods: {
    manageListApi:manageList,
    //获取银行卡列表
    getWallet(value){
      manageList({ pageNum: 1, pageSize: 20,network:value}).then(res=>{
        this.walletList = res.data.records;
        console.log(this.walletList)
      })
    },
    /** 查询用户完成线下理财信息列表 */
    getList() {
      this.loading = true;
      list(this.queryParams).then(response => {
        this.dataList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
      this.$modal.confirm('是否确认删除用户完成线下理财信息编号为"' + id + '"的数据项？').then(function () {
        return deleteData([id]);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
  }
};
</script>
